<?php
$dbh  = new  PDO ( 'mysql:host=localhost;dbname=mhsw' , 'root' , 'root' );
//$username=$_GET['username'];
//$sql="insert into jj (username,userpwd) VALUES(?,?)";
////对入住语句进行预处理
//$stmt=$dbh->prepare($sql);
//$stmt->bindParam(1,$username);
//$stmt->bindParam(2,$userpwd);
////给参数赋值
//$username=$_GET['username'];
//$userpwd=1314520;
//$stmt->execute();
$sql="delete from jj where id=15";
$sql1="delete from jj where uid=16";
//开启事务
$dbh->beginTransaction();
//执行sql语句
$query=$dbh->exec($sql);
$query1=$dbh->exec($sql1);
//满足条件
if($query&&$query1)
{
    $dbh->commit();//提交事务
}
else{
    $dbh->rollBack();//回滚事务
}
